package com.awx.client.rpc;

import java.io.File;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;

public class AwxRpc {

	private static final String PATH_CLIENT_XML = "WebContent\\WEB-INF\\remoting-client.xml";

	private static AwxRpc instance;
	private XmlBeanFactory factory;

	private AwxRpc() {
		Resource resource = new FileSystemResource( PATH_CLIENT_XML );
		factory = new XmlBeanFactory( resource );
	}

	public static AwxRpc getInstance() {
		if( instance == null ) {
			instance = new AwxRpc();
		}
		return instance;
	}

	public Object getServer( String serverName ) {
		return factory.getBean( serverName );
	}

}
